Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nullptr/NULL instead of 0 for pointers, two fixes for undefined behavior #4996

Merged
merged 1 commit into from
May 13, 2024

Conversation

jaakristioja
Copy link
Contributor

@jaakristioja jaakristioja commented May 9, 2024

This commit fixes most -Wzero-as-null-pointer-constant warnings, except in some places which appear to be vendored 3rd party libraries, e.g. in sdl_ttf.c, libchdr, physfs and gmock and in 3rd party components therein. Since it might make more sense to update this 3rd party code to some later versions instead of fixing the warnings manually, I decided not to enable the C++ compiler flag in configure.ac at this point.

In two functions with the return type of std::string executed return 0; statements, causing std::string to be constructed from a null pointer. To avoid undefined behavior these were changed to return {};.

…ehavior

This commit fixes most -Wzero-as-null-pointer-constant warnings, except in
some places which appear to be vendored 3rd party libraries, e.g. in sdl_ttf.c,
libchdr, physfs and gmock and in 3rd party components therein. Since it might
make more sense to update this 3rd party code to some later versions instead of
fixing the warnings manually, I decided not to enable the C++ compiler flag in
configure.ac at this point.

In two functions with the return type of std::string executed `return 0;`
statements, causing std::string to be constructed from a null pointer. To avoid
undefined behavior these were changed to `return {};`.

Signed-off-by: Jaak Ristioja <[email protected]>
@jaakristioja jaakristioja changed the title Use nullptr instead of 0 for pointers, two fixes for undefined behavior Use nullptr/NULL instead of 0 for pointers, two fixes for undefined behavior May 9, 2024
@joncampbell123 joncampbell123 merged commit 85eec1f into joncampbell123:master May 13, 2024
20 checks passed
@jaakristioja jaakristioja deleted the nullptr-fixes branch May 13, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants